#include "MainWindow.h"
#include "ui_MainWindow.h"

#include <QDebug>
#include <QDir>
#include <QFile>


#include "zDlgExcute.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QDir dir("./");
    QFileInfoList list = dir.entryInfoList(QStringList()<<"*.txt",QDir::Files);
    for(QFileInfo info : list)
    {
        qDebug()<< info.absoluteFilePath();
        m_listFilePath << info.filePath();
        ui->m_pNameCombo->addItem(info.baseName());
    }

    m_list = list;
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_m_pBtnStart_clicked()
{
    QString strName = "";
    for(QFileInfo info : m_list)
    {
        if( 0 == info.baseName().compare(ui->m_pNameCombo->currentText()))
        {
            strName = info.absoluteFilePath();
            break;
        }
    }

    this->hide();
    zDlgExcute dlg(this);
    dlg.SetFilePath(strName);
    dlg.exec();
    this->show();
}
